package org.an.proj.contacts.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * 创建时间：2016年10月14日13:46 <br>
 * 作者：fuchaoyang <br>
 * 描述：EventBus 发送event统一处理，便于维护
 * {@link EventTag}
 */

public class EventController {
  public static EventBus newInstance() {
    return EventBus.getDefault();
  }

  public static void post(Object event) {
    newInstance().post(event);
  }

  public static void register(Object subscriber) {
    newInstance().register(subscriber);
  }

  public static void unregister(Object subscriber) {
    newInstance().unregister(subscriber);
  }

  //=================

  /**
   * 是否开启侧滑
   *
   * @param isOpen 是否开启
   */
  public static void postToggleSlidingEvent(boolean isOpen) {
    post(new EventTag.TagToggleSliding(isOpen));
  }

  /**
   * 刷新联系人列表
   */
  public static void postRefreshContactsEvent() {
    post(new EventTag.TagRefreshContacts());
  }

  /**
   * 升级弹窗
   */
  public static void postUpdateEvent() {
    EventBus.getDefault().post(new UpdateEvent());
  }
}
